%{
#include<math.h>
#include<string.h>
%}
white [\t\n ]
digit [0-9]
letter [A-Za-z]
id ({letter}|_)({letter}|{digit}|_)*
string \".*\"
number [1-9]{digit}*|0

%%
{white}+    {}
{number}    { fprintf(yyout,"INTCON %s\n",yytext); }
"const"     { fprintf(yyout,"CONST %s\n",yytext); }


"float"     { fprintf(yyout,"RESERVED %s\n",yytext); }
"double"    { fprintf(yyout,"RESERVED %s\n",yytext); }
"char"      { fprintf(yyout,"RESERVED %s\n",yytext); }
"bool"      { fprintf(yyout,"RESERVED %s\n",yytext); }
"int"       { fprintf(yyout,"RESERVED %s\n",yytext); }


"break"     { fprintf(yyout,"BREAKTK %s\n",yytext); }
"continue"  { fprintf(yyout,"CONTINUETK %s\n",yytext); }
"if"        { fprintf(yyout,"IFTK %s\n",yytext); }
"else"      { fprintf(yyout,"ELSETK %s\n",yytext); }
"!"         { fprintf(yyout,"NOT %s\n",yytext); }
"&&"        { fprintf(yyout,"AND %s\n",yytext); }
"||"        { fprintf(yyout,"OR %s\n",yytext); }
"while"     { fprintf(yyout,"WHILETK %s\n",yytext); }
"return"    { fprintf(yyout,"RETURN %s\n",yytext); }
"end"       { fprintf(yyout,"RETURN %s\n",yytext); }
"+"         { fprintf(yyout,"PLUS %s\n",yytext); }
"-"         { fprintf(yyout,"MINU %s\n",yytext); }
"void"      { fprintf(yyout,"VOIDTK %s\n",yytext); }
"*"         { fprintf(yyout,"MULT %s\n",yytext); }
"/"         { fprintf(yyout,"DIV %s\n",yytext); }
"%"         { fprintf(yyout,"MOD %s\n",yytext); }
"<"         { fprintf(yyout,"LSS %s\n",yytext); }
"<="        { fprintf(yyout,"LEQ %s\n",yytext); }
">"         { fprintf(yyout,"GRE %s\n",yytext); }
">="        { fprintf(yyout,"GEQ %s\n",yytext); }
"=="        { fprintf(yyout,"EQL %s\n",yytext); }
"!="        { fprintf(yyout,"NEQ %s\n",yytext); }
"="         { fprintf(yyout,"ASSIGN %s\n",yytext); }
";"         { fprintf(yyout,"SEMICN %s\n",yytext); }
","         { fprintf(yyout,"COMMA %s\n",yytext); }
"{"         { fprintf(yyout,"LBRACE %s\n",yytext); }
"}"         { fprintf(yyout,"RBARCE %s\n",yytext); }
"["         { fprintf(yyout,"LBRACK %s\n",yytext); }
"]"         { fprintf(yyout,"RBRACK %s\n",yytext); }
"("         { fprintf(yyout,"LPARENT %s\n",yytext); }
")"         { fprintf(yyout,"RPARENT %s\n",yytext); }
{id}        { fprintf(yyout,"IDENFR  %s\n",yytext); }
{string}     { fprintf(yyout,"STRCON  %s\n",yytext); }

%%
int main()
{
  yyin=fopen("input.c","r");
  yyout=fopen("output.txt","w");
  yylex();
  return 0;
}
int yywrap()
{
return 1;
}

